getApp();

Component({
    properties: {
        info: {
            type: null
        }
    },
    data: {
        weekList: [ "一", "二", "三", "四", "五", "六", "日" ],
        monthDayList: [],
        currentYear: "",
        currentMonth: "",
        currentDay: "",
        today: "",
        selectedDate: "",
        signedList: [],
        isDisabledNextMonth: !0,
        sign_status: "",
        todayStyle: "is-today",
        nowTime: new Date().getTime(),
        is_active_start: "",
        is_active_end: ""
    },
    observers: {
        info: function(t) {
            t && (this.setData({
                is_active_start: t.active_start_timestamp,
                is_active_end: t.active_end_timestamp
            }), this.initCurrentDate());
        },
        currentMonth: function() {
            var t = new Date(), a = t.getFullYear(), e = t.getMonth() + 1;
            (this.data.currentYear > a || this.data.currentYear == a && this.data.currentMonth >= e) && this.setData({
                isDisabledNextMonth: !0
            });
        }
    },
    lifetimes: {
        created: function() {},
        ready: function() {},
        moved: function() {},
        detached: function() {}
    },
    methods: {
        tapDay: function(t) {
            var a = t.currentTarget.dataset.item;
            this.data.is_active_start > a.time || this.data.is_active_end < a.time || (this.setData({
                today: a.date
            }), a.date = this.formatIosDate(a.date), this.triggerEvent("postChild", a));
        },
        formatIosDate: function(t) {
            return t.replace(/\//g, "-");
        },
        formatTime: function(t) {
            return [ t.getFullYear(), t.getMonth() + 1, t.getDate() ].join("/");
        },
        formatZero: function(t) {
            return t;
        },
        initCurrentDate: function(t) {
            var a = this, e = t || new Date(), n = e.getFullYear(), c = e.getMonth() + 1, r = e.getDate();
            if (!t) {
                var i, o;
                o = c < 10 ? "0".concat(c) : c, i = r < 10 ? "0".concat(r) : r;
                var s = "".concat(n, "-").concat(o, "-").concat(i);
                this.setData({
                    today: s
                }), console.log(this.data.today);
            }
            this.setData({
                currentYear: n,
                currentMonth: c,
                currentDay: r
            }, function() {
                a.initMonthDayList();
            });
        },
        initMonthDayList: function() {
            var t = new Date(this.data.currentYear, this.data.currentMonth - 1, 1).getDay(), a = new Date(this.data.currentYear, this.data.currentMonth, 0).getDate(), e = [];
            if (0 == t) for (var n = 0; n < 6; n++) e.push(null); else for (var c = 0; c < t - 1; c++) e.push(null);
            for (var r = 1; r <= a; r++) if (this.data.currentMonth >= 1 && this.data.currentMonth < 10) if (r >= 1 && r < 10) {
                var i = {
                    day: r,
                    date: "".concat(this.data.currentYear, "-0").concat(this.data.currentMonth, "-0").concat(r),
                    time: new Date("".concat(this.data.currentYear, "/").concat(this.data.currentMonth, "/").concat(r)).getTime()
                };
                e.push(i);
            } else {
                var o = {
                    day: r,
                    date: "".concat(this.data.currentYear, "-0").concat(this.data.currentMonth, "-").concat(r),
                    time: new Date("".concat(this.data.currentYear, "/").concat(this.data.currentMonth, "/").concat(r)).getTime()
                };
                e.push(o);
            } else if (this.data.currentMonth >= 10) {
                if (r >= 1 && r < 10) {
                    var s = {
                        day: r,
                        date: "".concat(this.data.currentYear, "-").concat(this.data.currentMonth, "-0").concat(r),
                        time: new Date("".concat(this.data.currentYear, "/").concat(this.data.currentMonth, "/").concat(r)).getTime()
                    };
                    e.push(s);
                } else {
                    var h = {
                        day: r,
                        date: "".concat(this.data.currentYear, "-").concat(this.data.currentMonth, "-").concat(r),
                        time: new Date("".concat(this.data.currentYear, "/").concat(this.data.currentMonth, "/").concat(r)).getTime()
                    };
                    e.push(h);
                }
                if (this.currentMonth >= 1 && this.currentMonth < 10) if (r >= 1 && r < 10) {
                    var d = {
                        day: r,
                        date: "".concat(this.currentYear, "/0").concat(this.currentMonth, "/0").concat(r),
                        time: new Date("".concat(this.currentYear, "-").concat(this.currentMonth, "-0").concat(r)).getTime()
                    };
                    e.push(d);
                } else {
                    var u = {
                        day: r,
                        date: "".concat(this.currentYear, "/0").concat(this.currentMonth, "/").concat(r),
                        time: new Date("".concat(this.currentYear, "-").concat(this.currentMonth, "-").concat(r)).getTime()
                    };
                    e.push(u);
                } else if (this.currentMonth >= 10) if (r >= 1 && r < 10) {
                    var l = {
                        day: r,
                        date: "".concat(this.currentYear, "/").concat(this.currentMonth, "/0").concat(r),
                        time: new Date("".concat(this.currentYear, "-").concat(this.currentMonth, "-").concat(r)).getTime()
                    };
                    e.push(l);
                } else {
                    var D = {
                        day: r,
                        date: "".concat(this.currentYear, "/").concat(this.currentMonth, "/").concat(r),
                        time: new Date("".concat(this.currentYear, "-").concat(this.currentMonth, "-").concat(r)).getTime()
                    };
                    e.push(D);
                }
            }
            this.setData({
                monthDayList: e
            }), console.log(this.data.monthDayList);
        },
        handleSelectDate: function(t) {
            var a = t.currentTarget.dataset.item;
            a && this.setData({
                selectedDate: a.date
            });
        },
        handlePreMonth: function() {
            this.handleToggleMonth(-1);
        },
        handleNextMonth: function() {
            console.log("dddddddddddd", this.data.isDisabledNextMonth), this.handleToggleMonth(1);
        },
        handleToggleMonth: function(t) {
            var a = this;
            console.log("ddddddddd");
            var e = this.data.currentMonth += t, n = this.data.currentYear;
            e <= 0 ? (e = 12, n--) : e > 12 && (e = 1, n++), this.setData({
                currentYear: n,
                currentMonth: e
            }, function() {
                console.log("ddddddddd"), a.initMonthDayList(), a.triggerEvent("change", {
                    date: "".concat(n, "/").concat(e)
                });
            });
        }
    }
});